package com.dzk.eshop.util;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropsUtils {
	
	private static final Logger log = Logger.getLogger(PropsUtils.class);
	
	private static final Properties properties = new Properties();
	
	static {
		try {
			properties.load(PropsUtils.class.getClassLoader().getResourceAsStream("app.properties"));
		} catch (IOException e) {
			log.error("app.properties load failed.", e);
		}
	}
	
	public static String getProperty(String key) {
		return properties.getProperty(key);
	}
	
	public static String getProperty(String key, Object... paramValues) {
		String value = properties.getProperty(key);
		if (paramValues != null && paramValues.length > 0) {
			for (int i = 0; i < paramValues.length; i++) {
				value = value.replace("{" + i + "}", paramValues[i].toString());
			}
		}
		return value;
	}

}
